package com.quanyan.place.web;

import com.quanyan.api.APIResponse;
import com.quanyan.api.enums.ApiResponseEnum;
import com.quanyan.common.Plugin.PageObj;
import com.quanyan.place.entity.apireq.ReqVisitedVo;
import com.quanyan.place.entity.apiresp.RespVisitInfo;
import com.quanyan.place.entity.vo.VisitedFromDataVo;
import com.quanyan.place.service.PlaceInnerService;
import com.quanyan.place.service.impl.VisitedService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * Created by liuyaoxin on 2016/6/16.
 */

@RestController
@RequestMapping("/admin/api/place/visited")
public class VisitedController {
    @Autowired
    PlaceInnerService placeService;

    @Autowired
    VisitedService visitedService;

    private Logger logger = LoggerFactory.getLogger(VisitedController.class);


        /*
        新增拜访记录
         */
   @RequestMapping(value="/importVisitedRecord",method = RequestMethod.POST)
   public APIResponse<?>importVisitedRecord(@RequestBody VisitedFromDataVo visitedFromDataVo){
       APIResponse apiResponse=visitedService.importVisitedRecord(visitedFromDataVo);
       return apiResponse;
   }


    /*
        查找拜访记录
         */
    @RequestMapping(value="/selectVisitedRecord",method = RequestMethod.GET)
   public APIResponse<?>selectVisitedRecord(ReqVisitedVo reqVisitedVo){
          APIResponse result= visitedService.selectVisitedRecord(reqVisitedVo);
             return result;
    }

    /*
    查找拜访记录列表 （分页）
     */
    @RequestMapping(value="/selectVisiteRecordList",method = RequestMethod.POST)
    public APIResponse selectVisiteRecordList(@RequestBody ReqVisitedVo reqVisitedVo){

           return visitedService.selectVisitedRecordList(reqVisitedVo);
    }

    /*
        修改拜访记录
         */
    @RequestMapping(value="/updateVisitedRecord",method=RequestMethod.POST)
     public APIResponse<?>updateVisitedRecord(@RequestBody  @Valid VisitedFromDataVo visitedFromDataVo, BindingResult bindingResult){
        if (bindingResult.hasErrors()) {
            return APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
     APIResponse apiResponse=visitedService.updateVisitedRecord(visitedFromDataVo);
    return apiResponse;
}

}
